import numpy as np
from complexityMeasure.CalcComplexity import CalcComplexity


class SampleSize:

    @staticmethod
    def samplesize(complexity, E, z=1.96):
        size = (z * 1.0 / E) ** 2
        size = 5 * size * complexity
        return size


if __name__ == '__main__':

    # c1Lst = np.linspace(0.1, 0.9, num=9, endpoint=True)
    # eLst = np.linspace(0.01, 0.1, num=10, endpoint=True)
    # z = 1.96
    # samplesize = np.empty((len(eLst), len(c1Lst)))
    # for i, e in enumerate(eLst):
    #     for j, c1 in enumerate(c1Lst):
    #         samplesize[i, j] = SampleSize.samplesize(complexity=c1, E=e, z=z)
    # print(samplesize)
    #
    print(SampleSize.samplesize(complexity=0.607, E=0.05, z=1.96))

    d = 2
    paiLst = np.array( [17977, 22023])
    paiLst = paiLst / sum(paiLst)

    cc = CalcComplexity(d)
    cc.K = len(paiLst)
    cc.paiList = paiLst
    cc.calcEntropy()
    print(cc.calc())
    print(SampleSize.samplesize(complexity=cc.calc(), E=0.05, z=1.96))
